package com.rocsun.base;

import lombok.Getter;

/**
 * @program: rocsun-scali
 * @description:
 * @author: yx.guo
 * @create: 2025-10-19 17:25
 **/
@Getter
public class RocsunException extends RuntimeException{

    /** 错误码 */
    private final Integer code;

    /** 错误信息 */
    private final String message;

    /**
     * 通过枚举构造异常
     */
    public RocsunException(RocsunErrorCodeEnum errorCodeEnum) {
        super(errorCodeEnum.getMessage());
        this.code = errorCodeEnum.getCode();
        this.message = errorCodeEnum.getMessage();
    }

    /**
     * 自定义错误信息
     */
    public RocsunException(Integer code, String message) {
        super(message);
        this.code = code;
        this.message = message;
    }

    /**
     * 默认通用异常（使用 FAIL）
     */
    public RocsunException(String message) {
        super(message);
        this.code = RocsunErrorCodeEnum.FAIL.getCode();
        this.message = message;
    }

}
